<%-- 
    Document   : crearalumno
    Created on : 12-nov-2010, 10:56:26
    Author     : Sara
--%>

<%@page import="com.ipartek.formacion.gestformwww.modelo.beans.Alumno"%>
<%@page import="com.ipartek.formacion.gestformwww.controlador.Verificador"%>
<%@page import="com.ipartek.formacion.gestformwww.modelo.beans.Procedencia"%>
<%@page import="com.ipartek.formacion.gestformwww.modelo.beans.Empresa"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.ResourceBundle"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@include file="validarusuario.jsp" %>
<% Alumno alumno;
if (request.getAttribute("alumnoAnterior")!=null){
    alumno=(Alumno)request.getAttribute("alumnoAnterior");
    }
else if (request.getAttribute("Alumno")!=null){
    alumno=(Alumno)request.getAttribute("Alumno");
    }else{
    alumno= new Alumno();
    }%>
<div class="contenido">    
    <form name="form1" action="crear-alumno-accion.do" method="POST" onsubmit="return validarFormCrearAlumno(this);" >
        <input type="hidden" name="modificacionCrear" value="<%= alumno.getAluId() %>" />
        <input type="hidden" name="aleatorioCrearAlumno" value="<%=Math.random()%>" />
        <input type="hidden" name="idCurso" value="<%=request.getParameter("idCurso")%>" />
        <div class="errordatos">
            <% if (session.getAttribute("errores") != null) {
                            ResourceBundle bundle = (ResourceBundle) application.getAttribute("errores-mapeo");
                            for (String i : (ArrayList<String>) session.getAttribute("errores")) {%>
            <%=bundle.getString(i)%><br>
            <%}
                                session.removeAttribute("errores");
                            }%>
        </div>
        <h4>
            <table width="100%">
                <tr>
                    <td width="17%"><font id="obligatorio">*</font>Nombre:</td>
                    <td width="33%"><input type="text" tabindex="1" maxlength="25" name="aluNom" value="<%=Verificador.comprobar(alumno.getAluNom())%>" onKeyUp="if (!validarCaracteres(this.value, true)) this.value=cadenaCorrecta(this.value);"/></td>
                    <td width="20%"><font id="obligatorio">*</font>NIF:</td>
                    <td width="30%"><input type="text" tabindex="7" size="12" maxlength="9" name="aluNIF" value="<%=Verificador.comprobar(alumno.getAluNIF())%>" onblur="if (!comprobarDNI(this.value, true)) this.value=this.value;"/></td>
                </tr>

                <tr>
                    <td><font id="obligatorio">*</font>Primer Apellido:</td>
                    <td><input type="text" tabindex="2" maxlength="25" name="aluApe1" value="<%=Verificador.comprobar(alumno.getAluApe1())%>" onKeyUp="if (!validarCaracteres(this.value, true)) this.value=cadenaCorrecta(this.value);"/></td>
                    <td>Nº Seg. Social:</td>
                    <td><input type="text" tabindex="8" maxlength="12" name="aluNSS" value="<%=Verificador.comprobar(alumno.getAluNSS())%>" onKeyUp="if (!validarNumero(this.value, false, true)){ this.value=cadenaCorrecta(this.value); this.value=borrarCaracterDeNumero(this.value);}"/></td>
                </tr>
                <tr>
                    <td><font id="obligatorio">*</font>Segundo Apellido:</td>
                    <td><input type="text" tabindex="3" maxlength="25" name="aluApe2" value="<%=Verificador.comprobar(alumno.getAluApe2())%>" onKeyUp="if (!validarCaracteres(this.value, true)) this.value=cadenaCorrecta(this.value);"/></td>
                    <td>Tel&eacute;fono 1:</td>
                    <td><input type="text" tabindex="9" maxlength="9" name="aluTlf1" value="<%=Verificador.comprobar(alumno.getAluTlf1())%>" onblur="if (!comprobarTelefono(this.value)) this.value='';"/></td>
                </tr>
                <tr>
                    <td>Direcci&oacute;n:</td>
                    <td><input type="text" tabindex="4" maxlength="50" name="aluDir" value="<%=Verificador.comprobar(alumno.getAluDir())%>" onKeyUp="if (!validarCaracteres(this.value, true)) this.value=cadenaCorrecta(this.value);"/></td>
                    <td>Tel&eacute;fono 2:</td>
                    <td><input type="text" tabindex="10" maxlength="9" name="aluTlf2" value="<%=Verificador.comprobar(alumno.getAluTlf2())%>" onblur="if (!comprobarTelefono(this.value)) this.value='';"/></td>
                </tr>
                <tr>
                    <td>Localidad:</td>
                    <td><input type="text" tabindex="5" maxlength="50" name="aluLocalidad" value="<%=Verificador.comprobar(alumno.getAluLocalidad())%>" onKeyUp="if (!validarCaracteres(this.value, true)) this.value=cadenaCorrecta(this.value);"/></td>
                    <td>Mail:</td>
                    <td><input type="text" tabindex="11" size="20" maxlength="50" name="aluMail" value="<%=Verificador.comprobar(alumno.getAluMail())%>" onblur="if (!comprobarMail(this.value)){ this.value=cadenaCorrecta(this.value);}else{ this.value=cadenaCorrecta(this.value);}"/></td>
                </tr>
                <tr>
                    <td>Fecha&nbsp;de nacimiento:</td>
                    <td><input type="text" tabindex="6" size="8" name="aluFechNac" id="aluFechNac" value="<%=Verificador.comprobar(alumno.getAluFechNac())%>" onClick="popUpCalendar(this,form1.aluFechNac,'dd/mm/yyyy');" value="<%if (request.getParameter("aluFechNac") != null) {%><%= request.getParameter("aluFechNac")%><%}%>" readonly /></td>
                </tr>
                <tr>
                    <td>Empresa:</td>
                    <td><select style="width: 150px" tabindex="12" name="empId" style="display:inline">
                            <option value="">&nbsp;</option>
                            <% ArrayList<Empresa> empresas = (ArrayList<Empresa>) request.getAttribute("listaEmpresas");
                                        if (empresas != null) {
                                            for (Empresa empresa : empresas) {%>
                            <option <%if (alumno.getEmpId() != null) {
                                                    if (alumno.getEmpId() == empresa.getEmpId()) {%> selected <% }
                                                                        }%> value="<%=empresa.getEmpId()%>"><%=empresa.getEmpNom()%> </option>
                            <%}
                                            }%>
                        </select><input tabindex="14" type="text" name="empNom" style="display:none" value="" maxlength="50" onKeyUp="if (!validarCaracteres(this.value,true)) this.value=this.value=cadenaCorrecta(this.value);"/>
                        <a tabindex="13" href="#" onclick="javascript:if(document.form1.empId.style.display=='inline'){document.form1.empId.style.display='none';document.form1.empNom.style.display='inline';}else{document.form1.empId.style.display='inline';document.form1.empNom.style.display='none';}">&nbsp;Lista/Nuevo</a></td>
                    <td>Procedencia:</td>
                    <td><select style="width: 150px" tabindex="15" name="proId" style="display:inline">
                            <option value="">&nbsp;</option>
                            <% ArrayList<Procedencia> procedencias = (ArrayList<Procedencia>) request.getAttribute("listaProcedencias");
                                    if (procedencias != null) {
                                        for (Procedencia procedencia : procedencias) {%>
                            <option <%if (alumno.getProId() != null) {
                                if (alumno.getProId() == procedencia.getProId()) {%> selected <% }
                                                                        }%>value="<%=procedencia.getProId()%>"><%=procedencia.getProDescr()%> </option>
                            <%}
                                        }%>
                        </select>&nbsp;<input tabindex="17" style="display: none;" name="proNom" value="" maxlength="50" onKeyUp="if (!validarCaracteres(this.value,true)) this.value=this.value=cadenaCorrecta(this.value);"/><a tabindex="16" href="#" onclick="javascript:if(document.form1.proId.style.display=='inline'){document.form1.proId.style.display='none';document.form1.proNom.style.display='inline';}else{document.form1.proId.style.display='inline';document.form1.proNom.style.display='none';}">&nbsp;<br>Lista/Nuevo</a></td>
                </tr>
            </table>
            <table>
                <tr>
                    <td  width="100%" colspan="4">Observaciones:&nbsp;(hasta&nbsp;500&nbsp;carácteres)</td>
                </tr>
                <tr>
                    <td width="100%" colspan="4"><textarea tabindex="18" onkeydown="if(this.value.length >= 500){  alert ('Has superado el tamaño máximo permitido'); this.value=this.value.substr(0,500); return false; }" name="aluObserv" rows="3" cols="150" onkeyup="if (!validarCaracteres(this.value, true)) this.value=cadenaCorrecta(this.value);"><%=Verificador.comprobar(request.getParameter("aluObserv"))%></textarea></td>
                </tr>
            </table>
        </h4>
        <div>Los&nbsp;campos&nbsp;marcados&nbsp;con&nbsp;<font id="obligatorio">*</font>&nbsp;son&nbsp;obligatorios.    </div>
    </form>
</div>
<div>
    <table>
        <tr>
            <td>&nbsp</td>
            <td>&nbsp</td>
            <td>&nbsp</td>
        </tr>
    </table>
</div>
